<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .test {
            border: 1px solid red;
        }

        canvas {
            margin-top: 40px;
            /* border: 4px solid rebeccapurple; */
        }

        #grad1 {
            height: 100px;
            background-color: red;
            box-shadow: 1px 1px 20px #000;
            background-image: linear-gradient(to left, #e66465, #9198e5, green);

            /* 暂未实现以下形式解析 */
            /* background-image:linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); */
            /* background-image: linear-gradient(-90deg,#e66465, #9198e5); */
        }

        #grad2 {
            height: 100px;
            background-color: red;
            box-shadow: 1px 1px 20px #000;
            background-image: linear-gradient(to top, #e66465, #9198e5, green);
            /* 暂未实现以下形式解析 */
            /* background-image:linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); */
            /* background-image: linear-gradient(-90deg,#e66465, #9198e5); */
        }

        #grad3 {
            height: 100px;
            background-color: red;
            box-shadow: 1px 1px 20px #000;
            background-image: linear-gradient(to right, #e66465, #9198e5, green);
            /* 暂未实现以下形式解析 */
            /* background-image:linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); */
            /* background-image: linear-gradient(-90deg,#e66465, #9198e5); */
        }

        #grad4 {
            height: 100px;
            background-color: red;
            box-shadow: 1px 1px 20px #000;
            background-image: linear-gradient(to bottom, #e66465, #9198e5, green);
            /* 暂未实现以下形式解析 */
            /* background-image:linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); */
            /* background-image: linear-gradient(-90deg,#e66465, #9198e5); */
        }

        #grad5 {
            height: 100px;
            background-color: red;
            box-shadow: 1px 1px 20px #000;
            background-image: linear-gradient(#e66465, #9198e5, green);
            /* 暂未实现以下形式解析 */
            /* background-image:linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); */
            /* background-image: linear-gradient(-90deg,#e66465, #9198e5); */
        }
    </style>
</head>

<body>
    <h1>canvas绘制测试1 图片合成测试 ，渐变测试 ，按钮测试</h1>
    <div class="test">
        <button>我是按钮</button>
        <h3>从左向右渐变</h3>
        <div id="grad1">啦啦啦 </div>
        <h3>从上到下渐变</h3>
        <div id="grad2"></div>

        <h3>从右到左渐变</h3>
        <div id="grad3"></div>
        <h3>从下到上渐变</h3>
        <div id="grad4"></div>
        <h3>默认从下到上渐变</h3>
        <div id="grad5"></div>
    </div>
    <h1>canvas绘制</h1>
    <canvas id="canvas"></canvas>
</body>
<script src="../dist/main.js"></script>

<script>
    const root = document.querySelector(".test")

    layout(root, 'canvas')
    let timer;
    window.addEventListener('resize', () => {
        if (timer) { clearTimeout(timer) }
        timer = setTimeout(function () {
            layout(root, 'canvas')

        }, 100);
    })
</script>

</html>